package com.san.dissertation.analytics;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import com.san.dissertation.analytics.model.ProcessInstanceVO;
import com.san.dissertation.utils.FacesUtils;
import com.san.test.BusinessService;
import com.san.dissertation.bpm.model.Process;
import com.san.dissertation.bpm.model.ProcessInstance;

public class ProcessInstanceController implements Serializable {

	private BusinessService businessService;

	public BusinessService getBusinessService() {
		return businessService;
	}

	public void setBusinessService(BusinessService businessService) {
		this.businessService = businessService;
	}

	public List<Process> getAllProcessDetails() {

		ProcessInstanceVO instanceVO = (ProcessInstanceVO) FacesUtils
				.getManagedBean("processInstanceVo");

		List<Process> processes = businessService.getAllProcessDetails();

		instanceVO.setProcesses(processes);

                return processes;
	}

	public String getProcessInstances(String processKey) {

		ProcessInstanceVO instanceVO = (ProcessInstanceVO) FacesUtils
				.getManagedBean("processInstanceVo");

		List<ProcessInstance> instances = businessService
				.getProcessInstanceDetails(processKey);
		
		instanceVO.setProcessInstance(instances);
		
		return "ProcessDetails";

	}
}
